#include<bits/stdc++.h>
#define ll long long
#define stdin stdin
#define stdout stdout
using namespace std;
const int MAXN=2e5+5;
int a[MAXN],T,n;
int find(int L,int R){
    if(R-L==1){
        if(a[L]==a[R]) return a[L];
        return 0;
    }
    int sum=0;
    for(int l=L;l<=R;l++){
        for(int r=R;r>=L;r--){
            if(a[l]==a[r]){
                sum+=a[l]+find(l+1,r-1);
                cout<<l<<r<<endl;
                l=r;
                break;
            }
        }

    }
    return 0;
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        printf("%d\n",find(1,n));
    }
    return 0;
}
